<template>
	<view class="page">
		<!-- 注意，如果需要兼容微信小程序，最好通过setRules方法设置rules规则 -->

		<u--form labelPosition="left" :model="model" :rules="rules" ref="form1">
			<u-form-item label="行业类别" label-width="80" borderBottom @click="gongzhongisShow = true; hideKeyboard()"
				ref="item1">
				<u--input v-model="hangyeType" disabled disabledColor="#ffffff" placeholder="请选择行业类别"
					border="none"></u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>
			<u-form-item label="岗位名称" label-width="80" prop="userInfo.title" borderBottom ref="item1">
				<u--input v-model="model.userInfo.title" placeholder="请选择岗位名称" border="none"></u--input>
			</u-form-item>
		
			<u-form-item v-if="isqujian==0" label="待遇工资" label-width="80" borderBottom ref="item1">
				<view style="display: flex;flex-direction: row;">
					<view style="display: flex;flex-direction: row;text-align: right;"
						@click="gudinggongziShow = true; hideKeyboard()">
						<u--input v-model="gudingxinzi" disabled disabledColor="#ffffff" placeholder="固定工资"
							suffixIcon="arrow-down" suffixIconStyle="color: #909399"></u--input>
						<!-- <u-icon slot="right" name="arrow-down"></u-icon> -->
					</view>
				</view>
			</u-form-item>
			<!-- <view class="form-item noh2 poser">
				<view class="item-label">姓名<text style="color: #f00;">*</text></view>
				<view class="item-input">
					<input type="text" v-model="FormData.nickName" maxlength="10" :adjustPosition="false" class="input-sc" placeholder="请输入姓名"/>
				</view>
			</view> -->
			<u-form-item v-if="isqujian==0" label="固定工资" label-width="80" borderBottom ref="item1">
				<view style="display: flex;flex-direction: row;">
					<!-- <view style="display: flex;flex-direction: row;">
						<u--input style="text-align: center;" v-model="model.userInfo.salaryMin"
							placeholder="请输入工资"></u--input>
					</view> -->
					<u--input style="text-align: center;width: 120px;margin-right: 10px;"
						v-model="model.userInfo.salaryMin" placeholder="请输入工资"></u--input>
					<view style="width: 100px;" @click="danweiShow = true; hideKeyboard()">
						<u--input v-model="danwei" disabled disabledColor="#ffffff" suffixIcon="arrow-down"
							suffixIconStyle="color: #909399"></u--input>
					</view>
				</view>
			</u-form-item>
			
			<u-form-item v-if="isqujian==1" label="待遇工资" label-width="80" borderBottom ref="item1">
				<view style="display: flex;flex-direction: row;">
					<view style="display: flex;flex-direction: row;text-align: right;"
						@click="gudinggongziShow = true; hideKeyboard()">
						<u--input v-model="gudingxinzi" disabled disabledColor="#ffffff" placeholder="区间工资"
							suffixIcon="arrow-down" suffixIconStyle="color: #909399"></u--input>
						<!-- <u-icon slot="right" name="arrow-down"></u-icon> -->
					</view>
				</view>
			</u-form-item>

			<u-form-item v-if="isqujian==1" label="区间工资" label-width="80" borderBottom ref="item1">
				<view style="display: flex;flex-direction: row;">
					<!-- <view style="display: flex;flex-direction: row;">
						<u--input style="text-align: center;" v-model="model.userInfo.salaryMin"
							placeholder="请输入工资"></u--input>
					</view> -->
					<u--input style="text-align: center;width: 40px;margin-right: 10px;"
						v-model="model.userInfo.salaryMin" placeholder="请输入最低工资"></u--input>
					<u--input style="text-align: center;width: 40px;margin-right: 10px;"
						v-model="model.userInfo.salaryMax" placeholder="请输入最高工资"></u--input>
					<view style="width: 100px;" @click="danweiShow = true; hideKeyboard()">
						<u--input v-model="danwei" disabled disabledColor="#ffffff" suffixIcon="arrow-down"
							suffixIconStyle="color: #909399"></u--input>
					</view>
				</view>
			</u-form-item>
			
			<u-form-item v-if="isqujian==2" label="待遇工资" label-width="80" borderBottom ref="item1">
				<view style="display: flex;flex-direction: row;">
					<view style="display: flex;flex-direction: row;text-align: right;"
						@click="gudinggongziShow = true; hideKeyboard()">
						<u--input v-model="gudingxinzi" disabled disabledColor="#ffffff" placeholder=""
							suffixIcon="arrow-down" suffixIconStyle="color: #909399"></u--input>
						<!-- <u-icon slot="right" name="arrow-down"></u-icon> -->
					</view>
				</view>
			</u-form-item>
			
			
			<u-form-item label="工作地点" label-width="80" prop="userInfo.address" borderBottom ref="item1">
				<!-- <u--input v-model="model.userInfo.address" placeholder="请输入工作地点或地图选择" border="none"></u--input> -->
				<!-- <u-button @click="chooseAddressClick">地图选择</u-button> -->
				<u--textarea autoHeight :maxlength="-1" placeholder="请输入工作地点或地图选择"
					v-model="model.userInfo.address"></u--textarea>
				<u-icon slot="right" @click="chooseAddressClick" size="28" :space="8" name="map-fill"></u-icon>
			</u-form-item>

			<u-form-item  label-width="80" prop="userInfo.workContent" borderBottom ref="item3">
				<u--textarea  :maxlength="-1" placeholder="请输入岗位描述"
					v-model="model.userInfo.workContent"></u--textarea>
			</u-form-item>
			
			<!-- <u-form-item label="福利待遇" label-width="80" borderBottom ref="item3">
				<view class="tag_container">
					<zyTag ref="zyAddTag" v-for="(item,index) in tagAddList" :text="item" addible />
					<view class="zy_tag_add">
					    <input :focus="focus" placeholder="+ New Tag" class="zy_tag_add_input"  v-model="addValue"
					        @confirm="confirm" />
					</view>
				</view>
			</u-form-item> -->
		<!-- 	<u-form-item label="结算方式" label-width="80" prop="userInfo.jiesuan" borderBottom
				@click="jiesuanShow = true; hideKeyboard()" ref="item1">
				<u--input v-model="jiesuan" disabled disabledColor="#ffffff" placeholder="请选择结算方式"
					border="none"></u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item> -->

			<!-- <u-form-item label="报名方式" label-width="80" borderBottom @click="baomingShow = true; hideKeyboard()"
				ref="item1">
				<u--input v-model="fangshi" disabled disabledColor="#ffffff" placeholder="请选择报名方式"
					border="none"></u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item> -->
			<u-form-item label="联系人" label-width="80" prop="userInfo.contractPeople" borderBottom ref="item1">
				<u--input v-model="model.userInfo.contractPeople" placeholder="请输入联系人姓名" border="none"></u--input>
			</u-form-item>
			<u-form-item label="联系电话" label-width="80" prop="userInfo.contractWays.mobile" borderBottom ref="item1">
				<u--input v-model="model.userInfo.contractWays.mobile" placeholder="请输入联系人电话" border="none"></u--input>
				<view slot="right" class="button-container"  @click="event => event.stopPropagation()">
				      <u-checkbox v-model="isChecked" @change="handleChange" label="微信同号"  :disabled='(model.userInfo.contractWays.mobile? false : true )'>
				         </u-checkbox>
				    </view>
			</u-form-item>
			<u-form-item label="微信号" label-width="80" prop="userInfo.contractWays.Wx" borderBottom ref="item1">
				<u--input v-model="model.userInfo.contractWays.Wx" placeholder="请输入联系人微信" border="none"></u--input>
			</u-form-item>
			<!-- <u-form-item label="邮箱" label-width="80" prop="userInfo.contractWays.email" borderBottom ref="item1">
				<u--input v-model="model.userInfo.contractWays.email" placeholder="请输入邮箱地址" border="none"></u--input>
			</u-form-item>
			<u-form-item label="招工二维码" label-width="80" prop="userInfo.contractWays.qrcode" borderBottom ref="item1">
				<u--input v-model="model.userInfo.contractWays.qrcode" placeholder="请上传二维码" border="none" disabled></u--input>
				<view slot="right">
					<u-button text="上传二维码" @click="chooseImage()"></u-button>
				</view>
			</u-form-item> -->
			
		
			
			
			
			
			<u-collapse :border="false"
			>
			  <u-collapse-item :border="false"
			    title="更多联系方式"
			  >
			    <u-form-item label="邮箱" label-width="80" prop="userInfo.contractWays.email" borderBottom ref="item1">
			    	<u--input v-model="model.userInfo.contractWays.email" placeholder="请输入邮箱地址" border="none"></u--input>
			    </u-form-item>
			  </u-collapse-item>
			</u-collapse>
			
			
			
		</u--form>
			<u-overlay :show="showuploadImage">
					<view class="autloading" style="width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;">
						<u-loading-icon :show="showuploadImage" color="white"></u-loading-icon>
					</view>
					
			</u-overlay>
		<view class="commitBg">
			<button class="btn" @click="submit">提交</button>
		</view>
		<!-- <u-button class="submit" @click="submit" type="success">提交</u-button> -->
		<!-- <u-button style="margin-top:150px;background-color: yellow;" @click="submit">提交</u-button> -->


		<u-action-sheet :show="gudinggongziShow" :actions="gongzitype" title="请选择工资类别" openType="launchApp"
			@close="gudinggongziShow = false;genderClose()" @select="gudingSelect">
		</u-action-sheet>
		<u-action-sheet :show="danweiShow" :actions="danweiunit" title="请选择工资单位" openType="launchApp"
			@close="danweiShow = false;genderClose()" @select="unitSelect">
		</u-action-sheet>
	<!-- 	<u-action-sheet :show="baomingShow" :actions="actions" title="请选择报名方式" openType="launchApp"
			@close="baomingShow = false;genderClose()" @select="baomingSelect">
		</u-action-sheet> -->
		<!-- <u-action-sheet :show="jiesuanShow" :actions="jiesuanType" title="请选择结算方式" openType="launchApp"
			@close="jiesuanShow = false;genderClose()" @select="jiesuanSelect">
		</u-action-sheet> -->
		<u-picker :show="show" ref="uPicker" :columns="columns" @cancel="show=false" @confirm="confirm"
			@change="changeHandler"></u-picker>
		<u-picker :show="gongzhongisShow" ref="gongzhongPicker" :columns="gongzhongcolumns" @confirm="hangyeConfirm"
			@change="bindMultiPickerColumnChange" @cancel="gongzhongisShow = false"></u-picker>
			
			
	</view>

</template>

<script>
	import zyTag from '../../components/zy-tag/zy-tag.vue'
	import * as util from '../../common/util.js'
	var formatLocation = util.formatLocation;
	import permision from "@/common/permission.js"

	import uTabbar from "@/components/uTabbar/uTabbar.vue";
	import pop from "@/components/ming-pop/ming-cityindex.vue"
	import store from '@/common/store.js'
	import Index from '@/common/index-model.js'
	import fun from '@/common/publicFun.js'
	let index = new Index();
	let that = null;

	export default {
		components: {
			zyTag
		},
		data() {
			return {
				showuploadImage:false,
				isChecked: false,
				tagAddList: [],
				focus: false,
				addValue: '',
				tagScss: {
					fontSize: "",
					height: "",
				},
				hasLocation: false,
				location: {},
				isqujian: 0,
				columns: [],
				columnData: [],
				show: false,
				gongzhongcolumns: [],
				gongzhongList: [],
				gongzhongdata: [],
				gongzhongisShow: false, // 是否显示工种选择

				gudinggongziShow: false, // 是否显示固定工资选择
				danweiShow: false, // 是否显示单位选择
				// baomingShow: false, // 是否显示报名方式选择
				// jiesuanShow: false, // 是否显示结算方式选择
				hangyeType: '建筑施工',
				gudingxinzi: '固定工资',
				// jiesuan: '日结',
				moeny: '',
				// fangshi: '电话微信或邮箱联系',
				danwei: '元/月',
				model: {
					userInfo: {
						entId:'',
						type: 0,
						title: '',
						mapFlag: 0,
						address: '',
						lon: '',
						lat: '',
						workContent: '',
						welfares: '',
						contractMethod: 0,
						contractPeople: '',
						contractMobile: '',
						contractwx: '',
						salaryUnit: 5,
						salaryMin: 0,
						salaryMax: 0,
						// settlement: 0,
						// skillLevel2: 0,
						// skillLevel3: 0,
						contractWays:{
							mobile:'',
							Wx:'',
							email:'',
						},
						
					}
				},
				actions: [{
						name: '电话微信或邮箱联系',
						index: 0
					},
					{
						name: '资料报名',
						index: 1
					},
					{
						name: '电话微信邮箱和报名均可',
						index: 2
					}
				],
				gongzitype: [{
						name: '固定工资',
						index: 0
					},
					{
						name: '区间工资',
						index: 1
					},
					{
						name: '面议',
						index: 2
					}
				],
				danweiunit: [],
				// jiesuanType: [],
				rules: {
					'userInfo.userName': {
						type: 'string',
						required: true,
						message: '请填写昵称',
						trigger: ['blur', 'change']
					},
					'userInfo.intro': {
						type: 'string',
						required: true,
						message: '请填写简介',
						trigger: ['change']
					}
				},
				radio: '',
				switchVal: false
			};
		},
		methods: {
			getUserInfo() {
				index.getPublicUserMember({}, 'client/individual/select/information', 'post', res => {
					if (res.data.code == 200 && res.data.success) {
						console.log(res.data.result)
						this.userinfo = res.data.result;
						this.model.userInfo.contractPeople = res.data.result.nickName
						this.model.userInfo.contractWays.mobile = res.data.result.mobile
					}
				})	
			},
			chooseImage() {
			  uni.chooseImage({
			    count: 1, // 最多选择一张图片
			    sizeType: ['compressed'], // 压缩图片
			    sourceType: ['album', 'camera'], // 选择图片的来源，相册或者相机
			    success: (res) => {
					console.log(res,"图片信息")
				  this.model.userInfo.contractWays.qrcode = res.tempFilePaths
			      this.tempFilePath = res.tempFilePaths;
			      this.imageUrl = res.tempFilePaths[0]; // 显示选择的图片
			    }
			  });
			},
			handleChange(){
				 if (this.isChecked) {
				        console.log('取消选中');
						this.isChecked = false
				      } else {
				        console.log('选中');
						this.isChecked = true
						this.model.userInfo.contractWays.Wx = this.model.userInfo.contractWays.mobile
				      }
			},
			launchapptest(e) {
				console.log('测试一下', e)
			},
			//添加标签input框回车事件
			confirm(e) {
				console.log('添加标签input框回车事件', e)
				this.tagAddList.push(e.detail.value)
				this.addValue = ''
			},
			async getLocation() {
				// #ifdef APP-PLUS
				let status = await this.checkPermission();
				if (status !== 1) {
					return;
				}
				// #endif
				// #ifdef MP-WEIXIN || MP-TOUTIAO || MP-QQ
				let status = await this.getSetting();
				if (status === 2) {
					this.showConfirm();
					return;
				}
				// #endif

				this.doGetLocation();
			},
			getSetting: function() {
				return new Promise((resolve, reject) => {
					uni.getSetting({
						success: (res) => {
							if (res.authSetting['scope.userLocation'] === undefined) {
								resolve(0);
								return;
							}
							if (res.authSetting['scope.userLocation']) {
								resolve(1);
							} else {
								resolve(2);
							}
						}
					});
				});
			},
			openSetting: function() {
				this.hideConfirm();
				uni.openSetting({
					success: (res) => {
						if (res.authSetting && res.authSetting['scope.userLocation']) {
							this.doGetLocation();
						}
					},
					fail: (err) => {}
				})
			},
			async checkPermission() {
				let status = permision.isIOS ? await permision.requestIOS('location') :
					await permision.requestAndroid('android.permission.ACCESS_FINE_LOCATION');

				if (status === null || status === 1) {
					status = 1;
				} else if (status === 2) {
					uni.showModal({
						content: "系统定位已关闭",
						confirmText: "确定",
						showCancel: false,
						success: function(res) {}
					})
				} else if (status.code) {
					uni.showModal({
						content: status.message
					})
				} else {
					uni.showModal({
						content: "需要定位权限",
						confirmText: "设置",
						success: function(res) {
							if (res.confirm) {
								permision.gotoAppSetting();
							}
						}
					})
				}

				return status;
			},
			chooseAddressClick() {
				console.log('选择起始地点')
				let url = "./addMap?str=" + "radd"
				index.navigate_to(url)
				uni.navigateTo({
					url: "/pagesC/release/addMap?str=" + "radd"
				})
			},
			getLon() {
				uni.getLocation({
					type: 'wgs84',
					geocode: true,
					success: (res) => {
						console.log(res, '====dddd===')
					},
					fail: (err) => {
						uni.getSetting({
							success: (rs) => {
								let status = rs.authSetting
								if (!status['scope.userLocation']) {
									uni.showModal({
										title: '是否授权当前位置',
										content: '需要获取您的地理位置，请确认授权，否则地图功能将无法开启',
										success: (tip) => {
											if (tip.confirm) {
												uni.openSetting({
													success: (data) => {
														if (data
															.authSetting[
																'scope.userLocation'
															] === true
														) {
															index
																.show_tips(
																	'授权成功')
															uni.getLocation({
																type: 'wgs84',
																success: (
																	nodes
																) => {
																	console
																		.log(
																			'99999999999',
																			nodes
																		)
																}
															})
														} else {
															index
																.show_tips(
																	'授权失败')
															return false
														}

													}
												})
											}
										}
									})
								} else {
									uni.getLocation({
										type: 'wgs84',
										success: (nodes) => {
											console.log('001001001', nodes)
										}
									})
								}
							},
							fail: (noerr) => {
								index.show_tips('调用授权窗口失败')
								return false
							}
						})
					}
				})
			},
			// 显示性别列表并校验性别是否为那女
			gudingSelect(e) {
				console.log('选择的工资方式是', e, e.name, e.index)
				this.isqujian = e.index
				this.gudingxinzi = e.name
				this.moeny = ""
			},
			unitSelect(e) {
				console.log('选择的工资单位是', e)
				this.model.userInfo.salaryUnit = e.index + 1
				this.danwei = e.name
			},
			// jiesuanSelect(e) {
			// 	console.log('选择的结算方式是', e)
			// 	this.model.userInfo.settlement = e.index + 1
			// 	this.jiesuan = e.name
			// 	if(e.index == 0){
			// 		this.model.userInfo.salaryUnit = 4
			// 		this.danwei = '元/天'
			// 	}
			// 	if(e.index == 1){	
			// 		this.model.userInfo.salaryUnit = 5
			// 		this.danwei = '元/月'
			// 	}
			// 	if(e.index == 2){
			// 		if((this.model.userInfo.salaryUnit !== 0)&&(this.model.userInfo.salaryUnit !== 1)&&(this.model.userInfo.salaryUnit !== 2)){
			// 			this.model.userInfo.salaryUnit = 1
			// 			this.danwei = '元/件'
			// 		}
			// 	}
			// 	if(e.index == 6){
			// 		this.model.userInfo.salaryUnit = 7
			// 		this.danwei = '元/周'
			// 	}
			// },
			// baomingSelect(e) {
			// 	console.log('选择的报名内容是', e)
			// 	this.fangshi = e.name
			// 	this.model.userInfo.contractMethod = e.index
			// },
			// 性别选择关闭,校验是否选择性别
			genderClose() {
				// this.$refs.form1.validateField('userInfo.gender')
			},
			changeHandler(e) {
				console.log('监听变化', e)
				const {
					columnIndex,
					value,
					values, // values为当前变化列的数组内容
					index,
					// 微信小程序无法将picker实例传出来，只能通过ref操作
					picker = this.$refs.uPicker
				} = e
				let inter = []
				// if (index == 0) {
				// 	inter.push('面议')
				// } else {
				for (let i = index + 1; i < index + 50; i++) {
					inter.push(i * 200)
				}
				// }
				this.columnData[index] = inter

				if (columnIndex === 0) {
					picker.setColumnValues(1, this.columnData[index])
				}
			},
			// 回调参数为包含columnIndex、value、values
			confirm(e) {
				console.log('confirm', e)
				this.model.userInfo.salaryMin = e.value[0]
				this.model.userInfo.salaryMax = e.value[1]
				this.moeny = e.value[0] + '~' + e.value[1]
				this.show = false
			},
			hangyeConfirm(e) {
				this.gongzhongisShow = false
			},
			//picker滑动改变时触发
			bindMultiPickerColumnChange(e) {
				console.log('监听变化', e)
				const {
					columnIndex,
					value,
					values, // values为当前变化列的数组内容
					index,
					// 微信小程序无法将picker实例传出来，只能通过ref操作
					picker = this.$refs.gongzhongPicker
				} = e
				console.log('第几列：' + columnIndex + '，下标值为：' + index + '=====' + e.indexs)
				// this.model.userInfo.type = this.gongzhongList[index].id
				// this.hangyeType = value[0]
				let arr = []
				for (let k = 0; k < this.gongzhongList.length; k++) {
					arr[k] = this.gongzhongList[k].skillName
				}
				// this.gongzhongcolumns.splice(0, 0, arr)
				console.log('行业类别0000', arr)
				let arr1 = []
				// for (let k = 0; k < this.gongzhongList[e.indexs[0]].children.length; k++) {
				// 	arr1[k] = this.gongzhongList[e.indexs[0]].children[k].skillName
				// }
				// console.log('行业类别2', arr1)
				// this.gongzhongcolumns.splice(1, 1, arr1)
				// console.log('行业类别111111', arr1)
				// let arr2 = []
				// for (let k = 0; k < this.gongzhongList[e.indexs[0]].children[e.indexs[1]].children.length; k++) {
				// 	arr2[k] = this.gongzhongList[e.indexs[0]].children[e.indexs[1]].children[k].skillName
				// }
				// // this.hangyeType = e.value[0]+'/'+e.value[1]+'/'+e.value[2]
				// console.log('行业类别3', this.hangyeType)
				// this.gongzhongcolumns.splice(2, 2, arr2)
				// console.log('行业类别222222', arr2)
				// if (columnIndex == 0) {
				// 	let arr1 = []
				// 	for (let k = 0; k < this.gongzhongList[e.indexs[0]].children.length; k++) {
				// 		arr1[k] = this.gongzhongList[e.indexs[0]].children[k].skillName
				// 	}
				// 	this.gongzhongcolumns.splice(1, 1, arr1)
				// 	let arr2 = []
				// 	for (let k = 0; k < this.gongzhongList[e.indexs[0]].children[e.indexs[1]].children.length; k++) {
				// 		arr2[k] = this.gongzhongList[e.indexs[0]].children[e.indexs[1]].children[k].skillName
				// 	}
				// 	// this.hangyeType = e.value[0]+'/'+e.value[1]+'/'+e.value[2]
				// 	console.log('行业类别3', this.hangyeType)
				// 	this.gongzhongcolumns.splice(2, 2, arr2)
				// }

				this.model.userInfo.type = this.gongzhongList[e.indexs[0]].id
				// this.model.userInfo.skillLevel2 = this.gongzhongList[e.indexs[0]].children[e.indexs[1]].id
				// this.model.userInfo.skillLevel3 = this.gongzhongList[e.indexs[0]].children[e.indexs[1]].children[e.indexs[
					// 2]].id
				this.hangyeType = this.gongzhongList[e.indexs[0]].skillName
			},
			//查询工种
			getQueryType() {
				
				let types = "construction"
				this.Qurylist = []
				index.getPublicMember({}, 'client/skills/listV2/' + types, 'get', res => {
					if (res.data.success && res.data.code == 200) {
						this.gongzhongList = res.data.result
						// this.gongzhongisShow=true
						let arr = []
						for (let k = 0; k < this.gongzhongList.length; k++) {
							arr[k] = this.gongzhongList[k].skillName
						}
						// this.gongzhongcolumns[0] = arr
						console.log('行业类别1', arr)
						// let arr1 = []
						// for (let k = 0; k < this.gongzhongList[0].children.length; k++) {
						// 	arr1[k] = this.gongzhongList[0].children[k].skillName
						// }
						// console.log('行业类别2', arr1)
						// // this.gongzhongcolumns[1] = arr1
						// let arr2 = []
						// for (let k = 0; k < this.gongzhongList[0].children[0].children.length; k++) {
						// 	arr2[k] = this.gongzhongList[0].children[0].children[k].skillName
						// }
						//console.log('行业类别3', arr2)
						// this.hangyeType = arr[0]
						// this.gongzhongcolumns[2] = arr2
						// this.gongzhongcolumns.splice(arr,arr1,arr2)
						this.gongzhongcolumns.push(arr)
					
						console.log('行业类别选择数据源', this.gongzhongcolumns)
						this.model.userInfo.type = this.gongzhongList[0].id

					}
				})
			},
			// 隐藏键盘
			hideKeyboard() {
				uni.hideKeyboard()
			},

			submit() {
				console.log("提交信息:" + JSON.stringify(this.model.userInfo))
				if (this.model.userInfo.title == "") {
					uni.showToast({
						title: "请输入职位名称",
						icon: "none"
					})
					return
				}
				if (this.model.userInfo.address == "") {
					uni.showToast({
						title: "工作地点不能为空",
						icon: "none"
					})
					return
				}
				if (this.isqujian == 0) {
					if (this.model.userInfo.salaryMin == 0) {
						uni.showToast({
							title: "请输入工资",
							icon: "none"
						})
						return
					}
				}
				if (this.isqujian == 1) {
					if (this.model.userInfo.salaryMax == 0) {
						uni.showToast({
							title: "请输入最大工资",
							icon: "none"
						})
						return
					}
					if (Number(this.model.userInfo.salaryMax) < Number(this.model.userInfo.salaryMin)) {
						uni.showToast({
							title: "最大工资不能小于最小工资",
							icon: "none"
						})
						return
					}
				}
				if (this.isqujian == 2) {
					this.model.userInfo.salaryMin=''
					this.model.userInfo.salaryMax=''
				}
				if (this.isqujian == 0) {
					this.model.userInfo.salaryMax= ''
				}
				if (this.model.userInfo.workContent == "") {
					uni.showToast({
						title: "请输入职位描述",
						icon: "none"
					})
					return
				}
				if(this.model.userInfo.contractMethod != 1){
					if (this.model.userInfo.contractWays.mobile == ""&&this.model.userInfo.contractWays.Wx ==""&&this.model.userInfo.contractWays.email =="") {
					
					uni.showToast({
						title: "请至少输入一种联系方式",
						icon: "none"
					})
					
					return
				}
				}
				
				if(this.model.userInfo.contractWays.mobile.length != 0){
					if (!/^\d{1,11}$/.test(this.model.userInfo.contractWays.mobile)) {
				    uni.showToast({
				        title: "请输入正确电话格式",
				        icon: "none"
				    });
				    return;
				}
				}
				
				if (this.model.userInfo.contractPeople == "") {
					uni.showToast({
						title: "请输入联系人",
						icon: "none"
					})
					return
				}
				
				this.model.userInfo.contractMobile = this.model.userInfo.contractWays.mobile
				let modell = this.model.userInfo.contractWays
				this.model.userInfo.contractWays = JSON.stringify(this.model.userInfo.contractWays)
				console.log("提交信息:" + JSON.stringify(this.model.userInfo))
				index.getPublicUserMember(this.model.userInfo, 'client/recuitjob/publish', 'post', res => {
					if (res.data.success && res.data.code == 200) {
						uni.showToast({
							title: '发布成功'
						})
															this.showuploadImage = false
						 uni.setStorageSync('fromPage', 'addjob'); // 存储来源信息
						uni.navigateBack()
					}else{
						this.model.userInfo.contractWays = modell
						console.log(res)
						uni.showToast({
							title: res.data.message,
							icon: "none"
						})
					}
				})
				
			},
			// uploadImage() {
			// 	if(this.tempFilePath){
			// 		index.show_tips('上传中')
			// 						this.showuploadImage = true
			// 						console.log("上传了图片",this.tempFilePath)
			// 		// 这里可以添加上传图片的逻辑，上传到服务器等
			// 		uni.uploadFile({
			// 		  url: index.img_url + 'client/public/upload?type=enterpriseLicense&file=' + this.tempFilePath,
			// 		  filePath: this.tempFilePath[0],
			// 		  name: 'file',
			// 		  formData: {
			// 		    // 可以添加额外的表单数据
			// 		  },
			// 						header: {
			// 							'X-Access-Token': uni.getStorageSync('token'),
			// 							'Login-Type': 'client'
			// 						},
			// 		  success: (res) => {
			// 		    // 上传成功的处理逻辑
			// 		    console.log('上传成功', res.data);
			// 						  this.model.userInfo.contractWays.qrcode = JSON.parse(res.data).result.url
			// 						  this.model.userInfo.contractMobile = this.model.userInfo.contractWays.mobile
			// 						  let modell = this.model.userInfo.contractWays
			// 						  this.model.userInfo.contractWays = JSON.stringify(this.model.userInfo.contractWays)
			// 						  console.log("提交信息:" + JSON.stringify(this.model.userInfo))
			// 						  index.getPublicUserMember(this.model.userInfo, 'client/recuitjob/publish', 'post', res => {
			// 						  	if (res.data.success && res.data.code == 200) {
			// 						  		uni.showToast({
			// 						  			title: '发布成功'
			// 						  		})
			// 								this.showuploadImage = false
			// 						  		uni.navigateBack()
			// 						  	}else{
			// 						  		this.model.userInfo.contractWays = modell
			// 						  		uni.showToast({
			// 						  			title: '发布失败请检查地点格式',
			// 						  			icon: "none"
			// 						  		})
			// 						  	}
			// 						  })
			// 		  },
			// 		  fail: (err) => {
			// 		    // 上传失败的处理逻辑
			// 		    console.error('上传失败', err);
			// 		  }
			// 		});
			// 	}else{
			// 		this.model.userInfo.contractMobile = this.model.userInfo.contractWays.mobile
			// 		let modell = this.model.userInfo.contractWays
			// 		this.model.userInfo.contractWays = JSON.stringify(this.model.userInfo.contractWays)
			// 		console.log("提交信息:" + JSON.stringify(this.model.userInfo))
			// 		index.getPublicUserMember(this.model.userInfo, 'client/recuitjob/publish', 'post', res => {
			// 			if (res.data.success && res.data.code == 200) {
			// 				uni.showToast({
			// 					title: '发布成功'
			// 				})
			// 													this.showuploadImage = false
			// 				uni.navigateBack()
			// 			}else{
			// 				this.model.userInfo.contractWays = modell
			// 				uni.showToast({
			// 					title: '发布失败请检查地点格式',
			// 					icon: "none"
			// 				})
			// 			}
			// 		})
			// 	}
				
			// },
			
			getUnitList() {
				index.getPublicMember({}, '/client/public/unit/of/money', 'get', res => {
					if (res.data.success && res.data.code == 200) {
						let data = res.data.result
						let arr = []
						for (let i = 0; i < res.data.result.length; i++) {
							arr.push({
								"name": res.data.result[i].unit,
								"index": res.data.result[i].id
							})
						}
						console.log('工资单位', arr)
						// this.danwei = arr[3].name
						// this.model.userInfo.salaryUnit = arr[3].index
						 this.danweiunit = arr
					}
				})
			},
			getjiesuanList() {
				index.getPublicMember({}, '/client/public/find/settlement', 'get', res => {
					if (res.data.success && res.data.code == 200) {
						let arr = []
						for (let i = 0; i < res.data.result.length; i++) {
							arr.push({
								"name": res.data.result[i].settlement,
								"index": res.data.result[i].id
							})
						}
						this.model.userInfo.settlement = arr[0].index
						this.jiesuan = arr[0].name
						this.jiesuanType = arr
					}
				})
			}

		},
		onLoad(e) {
			this.model.userInfo.entId = e.entid
			this.model.userInfo.address = e.address
			if(e.setdata){
				console.log("传过来要修改的data",JSON.parse(e.setdata))
				this.hangyeType = JSON.parse(e.setdata).data.typeName
				this.model.userInfo.title = JSON.parse(e.setdata).data.title
				if(JSON.parse(e.setdata).data.salaryMax&&JSON.parse(e.setdata).data.salaryMin){
					this.isqujian = 1
					this.gudingxinzi = '区间工资'
					this.model.userInfo.salaryMax = JSON.parse(e.setdata).data.salaryMax
					this.model.userInfo.salaryMin = JSON.parse(e.setdata).data.salaryMin
					this.model.userInfo.salaryUnit = JSON.parse(e.setdata).data.salaryUnit
					this.danwei = JSON.parse(e.setdata).data.unit
				}else if(JSON.parse(e.setdata).data.salaryMin){
					console.log("小")
					this.isqujian = 0
					this.gudingxinzi = '固定工资'
					this.model.userInfo.salaryMin = JSON.parse(e.setdata).data.salaryMin
					this.model.userInfo.salaryUnit = JSON.parse(e.setdata).data.salaryUnit
					this.danwei = JSON.parse(e.setdata).data.unit
				}else{
					console.log("面议")
					this.isqujian = 2
					this.gudingxinzi = '面议'
				}
				this.model.userInfo.workContent = JSON.parse(e.setdata).data.workContent
				this.model.userInfo.address = JSON.parse(e.setdata).data.address
				this.model.userInfo.contractPeople = JSON.parse(e.setdata).data.contractPeople
				this.model.userInfo.contractWays.mobile = JSON.parse(JSON.parse(e.setdata).data.contractWays).mobile
				this.model.userInfo.contractWays.Wx = JSON.parse(JSON.parse(e.setdata).data.contractWays).Wx
				this.model.userInfo.contractWays.email = JSON.parse(JSON.parse(e.setdata).data.contractWays).email
			}else{
				this.getUserInfo()
				this.getLon();
			}
			
			// let arr = ['面议']
			let arr = []
			for (let k = 0; k < 50; k++) {
				arr[k] = k * 100
			}
			// for (let i = index + 1; i < index + 50; i++) {
			// 	arr.push(i *100)
			// }
			this.columns[0] = arr
			console.log('columns\columns', this.columns)
		},
		onShow() {
			// 移除全局自定义事件监听器
			uni.$off('saveSelect');
			// 监听全局的自定义事件
			uni.$on('saveSelect', data => {
				console.log("返回的数据是", data)
				let arr = data.location.split(",")
				this.model.userInfo.address = data.name
				this.model.userInfo.lon = arr[0]
				this.model.userInfo.lat = arr[1]
			})
		},
		onReady() {
			//如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
			// this.$refs.form1.setRules(this.rules)
			this.getQueryType()
			this.getjiesuanList()
			this.getUnitList()
		}

	};
</script>

<style lang="scss">
	/* 白色 */
	$zy-classic-white: #ffffff;

	/* 灰色 */
	$zy-classic-grey: #e9e9e9;
	$zy-dark-grey: #999999;

	.container {
		width: 100%;
		height: 100vh;
		background-color: $zy-classic-white;
	}
	.u-cell__body{
		padding: 10px 0px !important;
	}
	.text {
		padding: 20rpx 0 0 20rpx;
		font-size: 26rpx;
		color: $zy-dark-grey;
	}

	.tag_container {
		display: flex;
		align-items: center;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.zy_tag_add {
		width: 150rpx;
		height: 50rpx; //medium：45rpx；small：40rpx；mini：35rpx
		padding: 5rpx 15rpx;
		margin: 5rpx 8rpx;
		border: 1rpx solid $zy-classic-grey;
		border-radius: 10rpx;
		text-align: center;
	}

	.zy_tag_add_input {
		margin: auto;
		width: 150rpx;
		height: 50rpx; //medium：45rpx；small：40rpx；mini：35rpx
		font-size: 28rpx; //medium：26rpx；small：24rpx；mini：22rpx
	}

	.page {
		margin: 15px;
		// background-color: gainsboro;
	}

	.commitBg {
		margin-top: 50px;
		border-radius: 8rpx;
		height: 45px;

		.btn {
			color: #fff;
			border-radius: 8rpx;
			background: #0575ff;
			font-size: 28rpx;
			height: 45px;
		}
	}
</style>
<style>
	@import url("@/static/css/publics.css");
	@import url("@/static/css/myedituserinfo.css");
</style>